import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA246+XROAde0IuxdMnGyz\n' +
  'nlB61Z8fcvMarpgKVz8B16DzENYIhpvV9JTvVsiDmyZW8djf8WTDVue+ZHdo1IkT\n' +
  'F5fd/TQBKmqNYp2963B9c98ARgMJA6BNnLx+HvB80yLFQf5RDedQYyTZ0XiLBUtj\n' +
  'lyGPy9pEg9edtOddmUdO1srSHLshvBVoLqweQPFG8pIuwT1s/2dzqY6OJV4VlQ2q\n' +
  'J7h/4TWalGkgf3E3muzeIcMFHGdPi/iwJaPlMUDsArhI1eGftsWB172hl7AToxYY\n' +
  '2lfrz7yznLEu1ccYMOxWEXUVzRvJ9Dd7PGAhXfo9vjFpvTdw92lMcss9stZ/jzYo\n' +
  'nwIDAQAB'

const publicKey1 = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDaJ9rXrLtuv+g18IF1q37/OEHD\n' +
  'gH2KVBjRhEr5cdYUiKp9Jh1o7E+3qdA15SbG6uvUh3lyjB/+g1L0xWNGLlQbIlIQ\n' +
  'Vn/xufNDMAXsgAaFn/JxYKtbTamCz6HIFiw8oupHLxTNVlx/3Mg6KKznC1uP27my\n' +
  '06V1K7772x6qrvgeGQIDAQAB';

//下面这个私钥在后台有体现


const privateKey1 = 'MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIhHY7J6M7PxoCAggA\n' +
  'MBQGCCqGSIb3DQMHBAiurTPNBvCDRQSCAoAC6a/SItTPCgvwVtH5cjv5yVDGbIR1\n' +
  'G3CcGiX3J0lUPqwv3L+DT3CDIYM+NBBYocON7alFjVGZIew4KznFmZbdGbAT7Jcq\n' +
  'HdoAym6k3OmlNJ4CxOEnr4uopTq8t8N2NqTuGbsryWZn2IjvNyWMe1WhjcmnXNtq\n' +
  'CKzpg0dkqszqLzprgukDN6kYscQ/kyfTy3gEV8+I7FNqWy+1vCXCJ3R7NWSzndB/\n' +
  'enesH/O1pe7TvJnj1cXcBY6u4fmpnaRHbJRn4MnY+tvm3hkiJO+hMecnGrtVMxoj\n' +
  'y9x7x5PHVijE8fW6dHTNcobyxyWSQSU2/qCLWXNzCCKYcwpsIprDWJLTmYHHKkwG\n' +
  '9RxA6pFKNHoyOB3oyClFiUzLtmsC13efrlc/zruN9ClLq+8Ul/t9LbTCrt/3r0q7\n' +
  'oGvMbPQXAmILszE4kQSy8Qg3+Jdqi/sciHZewR0XOX6gWHs8cb55RpjItO0CH1dD\n' +
  'QTVZLMBjaPeHluP7AeZqA7haIYAGA17E0D/6NG6GQ5TWVyz/uCZdQ2JaV+puXfye\n' +
  '9Zdbn2VvIy74uJWQwpuw/EjZr3St2eABRid4/FVrcmJNK4YtLqDpQ9bMU/06yCCC\n' +
  'HtIYclKj6iw21fv2CXLUcNHXStxQseEN2N1lzzoJl8AFD9XyZaw+W29JlRmnsNRn\n' +
  '76Q/BdoukUhQXWls89YFOdZWFou1TeIZllIMU8imqbiUJeMixCjAolFB6UlQ1I1P\n' +
  'RuCZHCKfdoLzVECDiwGhWbwssmeu7q2+rjwqPV8+eqSXGaDjxGt6f1AOqzmQHkiU\n' +
  'p6udx7lG+mMsTuGRar0eJVn0dQjVYjWE366wegQAOFVX08yYqlHTuJ4c';

// 公钥加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}


// 公钥解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

// 加密，仅仅用于本地存储
export function encrypt1(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey1) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密，本地解密
export function decrypt1(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey1) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
